﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using HA.Data.DisplayOptions2;
using HA.ModFlow.Controls.DisplayOptions;
using HA.Data;
namespace HA.ModFlow.Controls.Windows.DisplayOptions
{
    /// <summary>
    /// winDisplayOptionV2.xaml 的交互逻辑
    /// </summary>
    public partial class winDisplayOptionV2 : Window
    {
        public winDisplayOptionV2(DisplayOption2 disPlay, Grid3d grid3D)
        {
            InitializeComponent();
            this._DisplayOptions =(DisplayOption2) disPlay.Clone ();          
            this.DataContext = this.DisplayOptions;
            this.lvApp.DataContext = this.DisplayOptions;
            this.grid3D = grid3D;
            this._disPlayOptions2 = disPlay;



            //this._DisplayOptions.DoGrid3dData.Modflow.Drains.Enabled = false ;

            //this._DisplayOptions.DoGrid3dData.Modflow.DryCell.Enabled = false;
        }

      

        Grid3d grid3D;
        DisplayOption2 _disPlayOptions2;

        public DisplayOption2 DisPlayOptions2
        {
            get { return _disPlayOptions2; }           
        }
   
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.lvApp.Items.Clear();
            if (this.DisplayOptions.DoGrid3dData != null)
            {
                if (this._DisplayOptions.DoGrid3dData.IsShowTab)
                {
                    this.lvApp.Items.Add("3D 网格数据");
                }
            }           
            if (this.DisplayOptions.DoMapData != null)
            {
                if (this._DisplayOptions.DoMapData.IsShowTab)
                {
                    this.lvApp.Items.Add("Map数据");
                }
            }         


            if (this.lvApp.Items.Count > 0)
            {
                this.lvApp.SelectedIndex = 0;
            }
            int index = this.lvApp.SelectedIndex;
            if (index != -1)
            {
                string str = this.lvApp.Items[index].ToString();
                ShowRightOption(str);
            }
            else
            {
                this.tabSubContent.IsEnabled=false ;
                this.lvApp.Items.Clear();
            }
            SolidColorBrush solidColorBrush = new SolidColorBrush(Color.FromArgb(this._DisplayOptions.BackColor.A, this._DisplayOptions.BackColor.R, this._DisplayOptions.BackColor.G, this._DisplayOptions.BackColor.B));
            this.groundRectColor.Fill = solidColorBrush;
        }

        private void ShowRightOption(string str)
        {
           
            if (this.DisplayOptions.DoGrid3dData != null && str.Contains("3D 网格数据"))
            {
                if (this.DisplayOptions.DoGrid3dData.Particles != null)
                {
                    if (this._DisplayOptions.DoGrid3dData.Particles.IsShowTab)
                    {
                        this.tabPrec.Visibility = System.Windows.Visibility.Visible;
                        this.tabPrec.IsSelected = true;
                    }
                    else
                    {
                        this.tabPrec.Visibility = System.Windows.Visibility.Collapsed;
                    }
                }
                else
                {
                    this.tabPrec.Visibility = System.Windows.Visibility.Collapsed;
                }


                if (this.DisplayOptions.DoGrid3dData.Modflow != null)
                {
                    if (this._DisplayOptions.DoGrid3dData.Modflow.IsShowTab)
                    {
                        this.tabModflow.Visibility = System.Windows.Visibility.Visible;
                        this.tabModflow.IsSelected = true;
                    }
                    else
                    {
                        this.tabModflow.Visibility = System.Windows.Visibility.Collapsed;
                    }
                }
                else
                {
                    this.tabModflow.Visibility = System.Windows.Visibility.Collapsed;
                }
                if (this.DisplayOptions.DoGrid3dData.Grid3d != null)
                {
                    if (this._DisplayOptions.DoGrid3dData.Grid3d.IsShowTab)
                    {
                        this.tabgrid.Visibility = System.Windows.Visibility.Visible;
                        this.tabgrid.IsSelected = true;
                    }
                    else
                    {
                        this.tabgrid.Visibility = System.Windows.Visibility.Collapsed;
                    }
                }
                else
                {
                    this.tabgrid.Visibility = System.Windows.Visibility.Collapsed;
                }
            }
            else
            {
                this.tabgrid.Visibility = System.Windows.Visibility.Collapsed;
                this.tabModflow.Visibility = System.Windows.Visibility.Collapsed;
                this.tabPrec.Visibility = System.Windows.Visibility.Collapsed;
            }
            if (this.DisplayOptions.DoMapData != null && str.Contains("Map数据"))
            {
                if (this.DisplayOptions.DoMapData.Map != null)
                {
                    if (this._DisplayOptions.DoMapData.IsShowTab)
                    {
                        this.tabMap.Visibility = System.Windows.Visibility.Visible;
                        this.tabMap.IsSelected = true;
                    }
                    else
                    {
                        this.tabMap.Visibility = System.Windows.Visibility.Collapsed;
                    }

                }
                else
                {
                    this.tabMap.Visibility = System.Windows.Visibility.Collapsed;
                }
            }
            else
            {
               
                this.tabMap.Visibility = System.Windows.Visibility.Collapsed;
            }

            if (this.DisplayOptions.DoMapData == null && this.DisplayOptions.DoGrid3dData == null)
            {
                this.tabSubContent.IsEnabled=true ;
            }

            System.Drawing.Color color = new System.Drawing.Color();
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            if (this.DisplayOptions.DoGrid3dData != null)
            {
                if (this.DisplayOptions.DoGrid3dData.Modflow != null)
                {                   
                        color = this.DisplayOptions.DoGrid3dData.Modflow.Wells.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnCross.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, clr, this.DisplayOptions.DoGrid3dData.Modflow.Wells.DisplayShape);

                        color = this.DisplayOptions.DoGrid3dData.Modflow.Drains.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnCircularpoints.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, clr, this.DisplayOptions.DoGrid3dData.Modflow.Drains.DisplayShape);

                        color = this.DisplayOptions.DoGrid3dData.Modflow.Rivers.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnTriangle.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, clr, this.DisplayOptions.DoGrid3dData.Modflow.Rivers.DisplayShape);

                        color = this.DisplayOptions.DoGrid3dData.Modflow.GeneralHead.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnSquare.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, clr, this.DisplayOptions.DoGrid3dData.Modflow.GeneralHead.DisplayShape);

                        color = this.DisplayOptions.DoGrid3dData.Modflow.ConstantHead.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnDiamond.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, clr, this.DisplayOptions.DoGrid3dData.Modflow.ConstantHead.DisplayShape);

                        color = this.DisplayOptions.DoGrid3dData.Modflow.TransientData.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnTriangleNoFill.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, clr, this.DisplayOptions.DoGrid3dData.Modflow.TransientData.DisplayShape);

                        color = this.DisplayOptions.DoGrid3dData.Modflow.HorizFlowBarrier.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnLine.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(2, clr, this.DisplayOptions.DoGrid3dData.Modflow.HorizFlowBarrier.DisplayShape);

                        color = this.DisplayOptions.DoGrid3dData.Modflow.DryCell.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnDryCell.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, clr, this.DisplayOptions.DoGrid3dData.Modflow.DryCell.DisplayShape);

                        color = this.DisplayOptions.DoGrid3dData.Modflow.WaterTable.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnWaterTable.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(2, clr, this.DisplayOptions.DoGrid3dData.Modflow.WaterTable.DisplayShape);

                        color = this.DisplayOptions.DoGrid3dData.Modflow.MarkFloodedCell.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnMarkFloodedCell.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, clr, this.DisplayOptions.DoGrid3dData.Modflow.MarkFloodedCell.DisplayShape);


                      
                    
                }
            }
         
            //map-----------------------
            if (this.DisplayOptions.DoMapData != null)
            {
                if (this.DisplayOptions.DoMapData.Map != null)
                {
                   
                        color = this.DisplayOptions.DoMapData.Map.Barrier.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnBarrier.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, clr, this.DisplayOptions.DoMapData.Map.Barrier.DisplayShape);

                        color = this.DisplayOptions.DoMapData.Map.Drain.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnDrain.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, clr, this.DisplayOptions.DoMapData.Map.Drain.DisplayShape);

                        color = this.DisplayOptions.DoMapData.Map.GeneralHead.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnGeneralHead.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, clr, this.DisplayOptions.DoMapData.Map.GeneralHead.DisplayShape);

                        color = this.DisplayOptions.DoMapData.Map.IBound.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnIBound.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, clr, this.DisplayOptions.DoMapData.Map.IBound.DisplayShape);

                        color = this.DisplayOptions.DoMapData.Map.MassLoad.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnMassLoad.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, clr, this.DisplayOptions.DoMapData.Map.MassLoad.DisplayShape);

                        color = this.DisplayOptions.DoMapData.Map.River.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnRiver.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, clr, this.DisplayOptions.DoMapData.Map.River.DisplayShape);

                        color = this.DisplayOptions.DoMapData.Map.Seepage.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnSeepage.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, clr, this.DisplayOptions.DoMapData.Map.Seepage.DisplayShape);

                        color = this.DisplayOptions.DoMapData.Map.SpecifiedConc.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnSpecifiedConc.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, clr, this.DisplayOptions.DoMapData.Map.SpecifiedConc.DisplayShape);

                        color = this.DisplayOptions.DoMapData.Map.SpecifiedFlow.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnSpecifiedFlow.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, clr, this.DisplayOptions.DoMapData.Map.SpecifiedFlow.DisplayShape);

                        color = this.DisplayOptions.DoMapData.Map.SpecifiedHead.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnSpecifiedHead.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, clr, this.DisplayOptions.DoMapData.Map.SpecifiedHead.DisplayShape);

                        color = this.DisplayOptions.DoMapData.Map.Well.Color;
                        clr = Color.FromArgb(color.A, color.R, color.G, color.B);
                        this.btnWell.Content = this.DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, clr, this.DisplayOptions.DoMapData.Map.Well.DisplayShape);
                     
                   
                }
            }

        }

        DisplayOption2 _DisplayOptions;

        public DisplayOption2 DisplayOptions
        {
            get { return _DisplayOptions; }
            set { _DisplayOptions = value; }
        }

        private void btnGroundColor_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.ColorDialog dlg = new System.Windows.Forms.ColorDialog();
            dlg.Color = this._DisplayOptions.BackColor;
            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                SolidColorBrush solidColorBrush = new SolidColorBrush(Color.FromArgb(dlg.Color.A, dlg.Color.R, dlg.Color.G, dlg.Color.B));
                this.groundRectColor.Fill = solidColorBrush;
                this._DisplayOptions.BackColor = dlg.Color;
            }
        }

        private void btnContourOption_Click(object sender, RoutedEventArgs e)
        {
            this._disPlayOptions2.DoGrid3dData.Grid3d.Contour.SetIsNeedUpdateDataToFalse();
            HA.ModFlow.Controls.Windows.DisplayOptions.winContourOptionV2 win = new HA.ModFlow.Controls.Windows.DisplayOptions.winContourOptionV2(this._disPlayOptions2.DoGrid3dData.Grid3d.Contour);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                //this._contourCopy.ResetContourLines(this._contourCopy.ContourLines);
                //this.DisplayOptions.DoGrid3dData.Grid3d.Contour.ReSetContourOption(win.ContourCopy);
                //this.DisplayOptions.DoGrid3dData.Grid3d.Contour.ResetDataAndTriggerEvent(win.ContourCopy);
              
                this._disPlayOptions2.DoGrid3dData.Grid3d.Contour.ResetDataAndTriggerEvent(win.ContourCopy);
            }
        }

        private void btnCross_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoGrid3dData.Modflow.Wells.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            HA.ModFlow.Controls.DisplayOptions.winSysbolAttributes win = new Controls.DisplayOptions.winSysbolAttributes(clr, this.DisplayOptions.DoGrid3dData.Modflow.Wells.Size, this.DisplayOptions.DoGrid3dData.Modflow.Wells.DisplayShape, this.DisplayOptions.DoGrid3dData.Modflow.Wells);           
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnCross.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, win.Clr2, win.Displayshape);

                //Color cl = win.Clr2;
                //this.DisplayOptions.DoGrid3dData.Modflow.Wells.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoGrid3dData.Modflow.Wells.Size = win.Size;
                //this.DisplayOptions.DoGrid3dData.Modflow.Wells.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoGrid3dData.Modflow.Wells = win.Entity;
            }
        }

        private void btnCircularpoints_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoGrid3dData.Modflow.Drains.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.DoGrid3dData.Modflow.Drains.Size, this.DisplayOptions.DoGrid3dData.Modflow.Drains.DisplayShape, this.DisplayOptions.DoGrid3dData.Modflow.Drains);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnCircularpoints.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                //Color cl = win.Clr2;
                //this.DisplayOptions.DoGrid3dData.Modflow.Drains.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoGrid3dData.Modflow.Drains.Size = win.Size;
                //this.DisplayOptions.DoGrid3dData.Modflow.Drains.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoGrid3dData.Modflow.Drains = win.Entity;
            }
        }

        private void btnTriangle_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoGrid3dData.Modflow.Rivers.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.DoGrid3dData.Modflow.Rivers.Size, this.DisplayOptions.DoGrid3dData.Modflow.Rivers.DisplayShape, this.DisplayOptions.DoGrid3dData.Modflow.Rivers);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnTriangle.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                //Color cl = win.Clr2;
                //this.DisplayOptions.DoGrid3dData.Modflow.Rivers.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoGrid3dData.Modflow.Rivers.Size = win.Size;
                //this.DisplayOptions.DoGrid3dData.Modflow.Rivers.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoGrid3dData.Modflow.Rivers = win.Entity;
            }
        }

        private void btnSquare_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoGrid3dData.Modflow.GeneralHead.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.DoGrid3dData.Modflow.GeneralHead.Size, this.DisplayOptions.DoGrid3dData.Modflow.GeneralHead.DisplayShape, this.DisplayOptions.DoGrid3dData.Modflow.GeneralHead);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnSquare.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                //Color cl = win.Clr2;
                //this.DisplayOptions.DoGrid3dData.Modflow.GeneralHead.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoGrid3dData.Modflow.GeneralHead.Size = win.Size;
                //this.DisplayOptions.DoGrid3dData.Modflow.GeneralHead.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoGrid3dData.Modflow.GeneralHead = win.Entity;
            }
        }

        private void btnDiamond_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoGrid3dData.Modflow.ConstantHead.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.DoGrid3dData.Modflow.ConstantHead.Size, this.DisplayOptions.DoGrid3dData.Modflow.ConstantHead.DisplayShape, this.DisplayOptions.DoGrid3dData.Modflow.ConstantHead);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnDiamond.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                //Color cl = win.Clr2;
                //this.DisplayOptions.DoGrid3dData.Modflow.ConstantHead.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoGrid3dData.Modflow.ConstantHead.Size = win.Size;
                //this.DisplayOptions.DoGrid3dData.Modflow.ConstantHead.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoGrid3dData.Modflow.ConstantHead = win.Entity;
            }
        }

        private void btnTriangleNoFill_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoGrid3dData.Modflow.TransientData.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.DoGrid3dData.Modflow.TransientData.Size, this.DisplayOptions.DoGrid3dData.Modflow.TransientData.DisplayShape, this.DisplayOptions.DoGrid3dData.Modflow.TransientData);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnTriangleNoFill.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                //Color cl = win.Clr2;
                //this.DisplayOptions.DoGrid3dData.Modflow.TransientData.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoGrid3dData.Modflow.TransientData.Size = win.Size;
                //this.DisplayOptions.DoGrid3dData.Modflow.TransientData.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoGrid3dData.Modflow.TransientData = win.Entity;
            }
        }

        private void btnLine_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoGrid3dData.Modflow.HorizFlowBarrier.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winLineProperty win = new winLineProperty(clr, this.DisplayOptions.DoGrid3dData.Modflow.HorizFlowBarrier.Size, this.DisplayOptions.DoGrid3dData.Modflow.HorizFlowBarrier.DisplayShape, this.DisplayOptions.DoGrid3dData.Modflow.HorizFlowBarrier);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnLine.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(2, win.Clr, win.Displayshape);
                //Color cl = win.Clr;
                //this.DisplayOptions.DoGrid3dData.Modflow.HorizFlowBarrier.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoGrid3dData.Modflow.HorizFlowBarrier.Size = win.Size;
                //this.DisplayOptions.DoGrid3dData.Modflow.HorizFlowBarrier.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoGrid3dData.Modflow.HorizFlowBarrier = win.Entity;
            }
        }

        private void btnDryCell_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoGrid3dData.Modflow.DryCell.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.DoGrid3dData.Modflow.DryCell.Size, this.DisplayOptions.DoGrid3dData.Modflow.DryCell.DisplayShape, this.DisplayOptions.DoGrid3dData.Modflow.DryCell);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnDryCell.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                //Color cl = win.Clr2;
                //this.DisplayOptions.DoGrid3dData.Modflow.DryCell.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoGrid3dData.Modflow.DryCell.Size = win.Size;
                //this.DisplayOptions.DoGrid3dData.Modflow.DryCell.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoGrid3dData.Modflow.DryCell = win.Entity;
            }
        }

        private void btnWaterTable_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoGrid3dData.Modflow.WaterTable.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winLineProperty win = new winLineProperty(clr, this.DisplayOptions.DoGrid3dData.Modflow.WaterTable.Size, this.DisplayOptions.DoGrid3dData.Modflow.WaterTable.DisplayShape, this.DisplayOptions.DoGrid3dData.Modflow.WaterTable);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnWaterTable.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(2, win.Clr, win.Displayshape);
                //Color cl = win.Clr;
                //this.DisplayOptions.DoGrid3dData.Modflow.WaterTable.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoGrid3dData.Modflow.WaterTable.Size = win.Size;
                //this.DisplayOptions.DoGrid3dData.Modflow.WaterTable.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoGrid3dData.Modflow.WaterTable = win.Entity;
            }
        }

        private void btnMarkFloodedCell_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoGrid3dData.Modflow.MarkFloodedCell.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.DoGrid3dData.Modflow.MarkFloodedCell.Size, this.DisplayOptions.DoGrid3dData.Modflow.MarkFloodedCell.DisplayShape, this.DisplayOptions.DoGrid3dData.Modflow.MarkFloodedCell);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnMarkFloodedCell.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                //Color cl = win.Clr2;
                //this.DisplayOptions.DoGrid3dData.Modflow.MarkFloodedCell.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoGrid3dData.Modflow.MarkFloodedCell.Size = win.Size;
                //this.DisplayOptions.DoGrid3dData.Modflow.MarkFloodedCell.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoGrid3dData.Modflow.MarkFloodedCell = win.Entity;
            }
        }

        private void btnSpecifiedHead_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoMapData.Map.SpecifiedHead.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.DoMapData.Map.SpecifiedHead.Size, this.DisplayOptions.DoMapData.Map.SpecifiedHead.DisplayShape, this.DisplayOptions.DoMapData.Map.SpecifiedHead);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnSpecifiedHead.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                //Color cl = win.Clr2;
                //this.DisplayOptions.DoMapData.Map.SpecifiedHead.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoMapData.Map.SpecifiedHead.Size = win.Size;
                //this.DisplayOptions.DoMapData.Map.SpecifiedHead.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoMapData.Map.SpecifiedHead = win.Entity;
            }
        }

        private void btnIBound_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoMapData.Map.IBound.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.DoMapData.Map.IBound.Size, this.DisplayOptions.DoMapData.Map.IBound.DisplayShape, this.DisplayOptions.DoMapData.Map.IBound);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnIBound.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                //Color cl = win.Clr2;
                //this.DisplayOptions.DoMapData.Map.IBound.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoMapData.Map.IBound.Size = win.Size;
                //this.DisplayOptions.DoMapData.Map.IBound.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoMapData.Map.IBound = win.Entity;
            }
        }

        private void btnSpecifiedConc_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoMapData.Map.SpecifiedConc.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.DoMapData.Map.SpecifiedConc.Size, this.DisplayOptions.DoMapData.Map.SpecifiedConc.DisplayShape, this.DisplayOptions.DoMapData.Map.SpecifiedConc);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnSpecifiedConc.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                //Color cl = win.Clr2;
                //this.DisplayOptions.DoMapData.Map.SpecifiedConc.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoMapData.Map.SpecifiedConc.Size = win.Size;
                //this.DisplayOptions.DoMapData.Map.SpecifiedConc.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoMapData.Map.SpecifiedConc = win.Entity;
            }
        }

        private void btnSpecifiedFlow_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoMapData.Map.SpecifiedFlow.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.DoMapData.Map.SpecifiedFlow.Size, this.DisplayOptions.DoMapData.Map.SpecifiedFlow.DisplayShape, this.DisplayOptions.DoMapData.Map.SpecifiedFlow);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnSpecifiedFlow.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                //Color cl = win.Clr2;
                //this.DisplayOptions.DoMapData.Map.SpecifiedFlow.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoMapData.Map.SpecifiedFlow.Size = win.Size;
                //this.DisplayOptions.DoMapData.Map.SpecifiedFlow.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoMapData.Map.SpecifiedFlow = win.Entity;
            }
        }

        private void btnGeneralHead_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoMapData.Map.GeneralHead.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.DoMapData.Map.GeneralHead.Size, this.DisplayOptions.DoMapData.Map.GeneralHead.DisplayShape, this.DisplayOptions.DoMapData.Map.GeneralHead);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnGeneralHead.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                //Color cl = win.Clr2;
                //this.DisplayOptions.DoMapData.Map.GeneralHead.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoMapData.Map.GeneralHead.Size = win.Size;
                //this.DisplayOptions.DoMapData.Map.GeneralHead.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoMapData.Map.GeneralHead = win.Entity;
            }
        }

        private void btnMassLoad_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoMapData.Map.MassLoad.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.DoMapData.Map.MassLoad.Size, this.DisplayOptions.DoMapData.Map.MassLoad.DisplayShape, this.DisplayOptions.DoMapData.Map.MassLoad);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnMassLoad.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                //Color cl = win.Clr2;
                //this.DisplayOptions.DoMapData.Map.MassLoad.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoMapData.Map.MassLoad.Size = win.Size;
                //this.DisplayOptions.DoMapData.Map.MassLoad.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoMapData.Map.MassLoad = win.Entity;
            }
        }

        private void btnDrain_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoMapData.Map.Drain.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.DoMapData.Map.Drain.Size, this.DisplayOptions.DoMapData.Map.Drain.DisplayShape, this.DisplayOptions.DoMapData.Map.Drain);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnDrain.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                //Color cl = win.Clr2;
                //this.DisplayOptions.DoMapData.Map.Drain.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoMapData.Map.Drain.Size = win.Size;
                //this.DisplayOptions.DoMapData.Map.Drain.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoMapData.Map.Drain = win.Entity;
            }
        }

        private void btnSeepage_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoMapData.Map.Seepage.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.DoMapData.Map.Seepage.Size, this.DisplayOptions.DoMapData.Map.Seepage.DisplayShape, this.DisplayOptions.DoMapData.Map.Seepage);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnSeepage.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                //Color cl = win.Clr2;
                //this.DisplayOptions.DoMapData.Map.Seepage.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoMapData.Map.Seepage.Size = win.Size;
                //this.DisplayOptions.DoMapData.Map.Seepage.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoMapData.Map.Seepage = win.Entity;
            }
        }

        private void btnRiver_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoMapData.Map.River.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.DoMapData.Map.River.Size, this.DisplayOptions.DoMapData.Map.River.DisplayShape, this.DisplayOptions.DoMapData.Map.River);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnRiver.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                //Color cl = win.Clr2;
                //this.DisplayOptions.DoMapData.Map.River.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoMapData.Map.River.Size = win.Size;
                //this.DisplayOptions.DoMapData.Map.River.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoMapData.Map.River = win.Entity;
            }
        }

        private void btnBarrier_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoMapData.Map.Barrier.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.DoMapData.Map.Barrier.Size, this.DisplayOptions.DoMapData.Map.Barrier.DisplayShape, this.DisplayOptions.DoMapData.Map.Barrier);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnBarrier.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                //Color cl = win.Clr2;
                //this.DisplayOptions.DoMapData.Map.Barrier.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoMapData.Map.Barrier.Size = win.Size;
                //this.DisplayOptions.DoMapData.Map.Barrier.DisplayShape = win.Displayshape;

                win.ConvertToRGBColor();
                this.DisplayOptions.DoMapData.Map.Barrier = win.Entity;
            }
        }

        private void btnWell_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.DoMapData.Map.Well.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.DoMapData.Map.Well.Size, this.DisplayOptions.DoMapData.Map.Well.DisplayShape, this.DisplayOptions.DoMapData.Map.Well);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                this.btnWell.Content = this._DisplayOptions.DoGrid3dData.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                //Color cl = win.Clr2;
                //this.DisplayOptions.DoMapData.Map.Well.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                //this.DisplayOptions.DoMapData.Map.Well.Size = win.Size;
                //this.DisplayOptions.DoMapData.Map.Well.DisplayShape = win.Displayshape;


                win.ConvertToRGBColor();
                this.DisplayOptions.DoMapData.Map.Well = win.Entity;
            }
        }

        private void btnVectorOption_Click(object sender, RoutedEventArgs e)
        {
            winVectorsOption win = new winVectorsOption(this._disPlayOptions2.DoGrid3dData.Grid3d.Vector);
            win.Owner = this;
            if (win.ShowDialog().Value)
            {
                if (this.grid3D != null)
                {

                    DSModflow ds = (DSModflow)grid3D.GetDatasetCollection(DataConstName.ModflowResult);

                    if (ds != null)
                    {
                        if (ds.VectorGridData != null)
                        {

                            if (win.DoVector.IsAutoCompLength)
                            {
                                int colindex = grid3D.ModFlowGrid.ColCoords.Length - 1;
                                int rowindex = grid3D.ModFlowGrid.RowCoords.Length - 1;
                                double col = grid3D.ModFlowGrid.ColCoords[colindex];
                                double row = grid3D.ModFlowGrid.RowCoords[rowindex];
                                double value = FlowVectorsAutoCompute.ComputeLength(grid3D.ModFlowGrid.ColsCount, grid3D.ModFlowGrid.RowsCount, col, row);
                                win.DoVector.Length = value;
                            }
                            if (win.DoVector.IsAutoCompScaling)
                            {

                                double range = ds.VectorGridData.MaxVectorValue - ds.VectorGridData.MinVectorValue;
                                double scaValue = FlowVectorsAutoCompute.ComputeScalingRatio(range, win.DoVector.Length);
                                win.DoVector.Scaling = scaValue;

                            }


                        }

                    }

                    //this._DisplayOptions.DoGrid3dData.Grid3d.Vector.ResetVecorOption(win.DoVector);
                    //this._disPlayOptions2.DoGrid3dData.Grid3d.Vector.ResetVecorOption(win.DoVector);
                    this._disPlayOptions2.DoGrid3dData.Grid3d.Vector.ResetDataAndTriggerEvent(win.DoVector);
                }

            }
        }

        private void lvApp_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int index = this.lvApp.SelectedIndex;
            if (index != -1)
            {
                string str = this.lvApp.Items[index].ToString();
                ShowRightOption(str);
            }
        }

        private void CheckModflowIsenble()
        {
            if (this._DisplayOptions.DoGrid3dData.Modflow.ConstantHead != this._disPlayOptions2.DoGrid3dData.Modflow.ConstantHead)
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = true;
                return;
            }
            else
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = false ;
            }
            if (this._DisplayOptions.DoGrid3dData.Modflow.Drains != this._disPlayOptions2.DoGrid3dData.Modflow.Drains)
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = true;
                return;
            }
            else
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = false;
            }

            if (this._DisplayOptions.DoGrid3dData.Modflow.DryCell != this._disPlayOptions2.DoGrid3dData.Modflow.DryCell)
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = true;
                return;
            }
            else
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = false;              
            }

            if (this._DisplayOptions.DoGrid3dData.Modflow.GeneralHead != this._disPlayOptions2.DoGrid3dData.Modflow.GeneralHead)
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = true;
                return;
            }
            else
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = false;          
            }

            if (this._DisplayOptions.DoGrid3dData.Modflow.HorizFlowBarrier != this._disPlayOptions2.DoGrid3dData.Modflow.HorizFlowBarrier)
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = true;
                return;
            }
            else
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = false;
            }

            if (this._DisplayOptions.DoGrid3dData.Modflow.MarkFloodedCell != this._disPlayOptions2.DoGrid3dData.Modflow.MarkFloodedCell)
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = true;
                return;
            }
            else
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = false;
            }

            if (this._DisplayOptions.DoGrid3dData.Modflow.Rivers != this._disPlayOptions2.DoGrid3dData.Modflow.Rivers)
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = true;
                return;
            }
            else
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = false;
            }

            if (this._DisplayOptions.DoGrid3dData.Modflow.TransientData != this._disPlayOptions2.DoGrid3dData.Modflow.TransientData)
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = true;
                return;
            }
            else
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = false;
            }

            if (this._DisplayOptions.DoGrid3dData.Modflow.WaterTable != this._disPlayOptions2.DoGrid3dData.Modflow.WaterTable)
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = true;
                return;
            }
            else
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = false;
            }

            if (this._DisplayOptions.DoGrid3dData.Modflow.Wells != this._disPlayOptions2.DoGrid3dData.Modflow.Wells)
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = true;
              
                return;
            }
            else
            {
                this._DisplayOptions.DoGrid3dData.Modflow.IsNeedUpdateData = false;
            }
        }

        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            CheckModflowIsenble();
            
            if (this.DisplayOptions.IsDataChanged())
            {
                this.DialogResult = true;
                this.Close();
            }
            else
            {
                this.Close();
            }

        }

        private void btnCancal_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }

  

}
